<?php

declare(strict_types=1);

use Hyperf\Database\Seeders\Seeder;

class InitAttractionManagementMenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $modelNames = [
            '景区' => [
                'name' => 'attraction:attraction',
                'i18n' => 'attraction.menu.attraction',
                'icon' => 'ep:office-building',
                'path' => '/attraction-management/attraction',
                'component' => 'attractions/attraction-management/views/attraction/index'
            ],
            '景点' => [
                'name' => 'attraction_spot:attractionSpot',
                'i18n' => 'attraction_spot.menu.attractionSpot',
                'icon' => 'ep:location',
                'path' => '/attraction-management/attractionSpot',
                'component' => 'attractions/attraction-management/views/attractionSpot/index'
            ],
            '预约' => [
                'name' => 'attraction_booking:attractionUserBooking',
                'i18n' => 'attraction_booking.menu.attractionUserBooking',
                'icon' => 'ep:tickets',
                'path' => '/attraction-management/attractionUserBooking',
                'component' => 'attractions/attraction-management/views/attractionUserBooking/index'
            ],
            '资讯' => [
                'name' => 'attraction_info:attractionInfo',
                'i18n' => 'attraction_info.menu.attractionInfo',
                'icon' => 'ep:info-filled',
                'path' => '/attraction-management/attractionInfo',
                'component' => 'attractions/attraction-management/views/attractionInfo/index'
            ],
            '位置' => [
                'name' => 'attraction_spot_position:attractionPosition',
                'i18n' => 'attraction_spot_position.menu.attractionSpotPosition',
                'icon' => 'ep:position',
                'path' => '/attraction-management/attractionSpotPosition',
                'component' => 'attractions/attraction-management/views/attractionSpotPosition/index'
            ],
            '标签' => [
                'name' => 'attraction_tags:attractionTags',
                'i18n' => 'attraction_tags.menu.attractionTags',
                'icon' => 'ep:price-tag',
                'path' => '/attraction-management/attractionTags',
                'component' => 'attractions/attraction-management/views/attractionTags/index'
            ],
            '游客' => [
                'name' => 'attraction_tourist_info:attractionTourist',
                'i18n' => 'attraction_tourist_info.menu.attractionUserTouristInfo',
                'icon' => 'ep:price-tag',
                'path' => '/attraction-management/attractionUserTouristInfo',
                'component' => 'attractions/attraction-management/views/attractionUserTouristInfo/index'
            ],
            '分类' => [
                'name' => 'attraction_type:attractionType',
                'i18n' => 'attraction_type.menu.attractionType',
                'icon' => 'ep:collection-tag',
                'path' => '/attraction-management/attractionType',
                'component' => 'attractions/attraction-management/views/attractionType/index'
            ],
            '用户' => [
                'name' => 'attraction_user:attractionUser',
                'i18n' => 'attraction_user.menu.attractionUser',
                'icon' => 'ep:collection-tag',
                'path' => '/attraction-management/attractionUser',
                'component' => 'attractions/attraction-management/views/attractionUser/index'
            ]
        ];
        $listName = [
            '列表' => ['name' => 'index', 'i18n' => ''],
            '新增' => ['name' => 'save', 'i18n' => ''],
            '编辑' => ['name' => 'update', 'i18n' => ''],
            '删除' => ['name' => 'delete', 'i18n' => '']
        ];
        $grandParent = \App\Model\Permission\Menu::create([
            'parent_id' => 0,
            'name'  => 'AttractionManagementRoute',
            'path'  =>  '/attraction-management',
            'component' => 'plugins/attractions/attraction-management/views/index.vue',
            'meta'  =>  new \App\Model\Permission\Meta([
                'type' => 'M',
                'title' => '景区管理',
                'i18n' => 'menu.attraction-management',
                'icon' => 'ep:map-location',
                'hidden' => 0,
                'componentPath' => 'plugins/',
                'componentSuffix' => '.vue',
                'breadcrumbEnable' => 1,
                'copyright' => 1,
                'cache' => 1,
                'affix' => 0,
            ]),
        ]);

        foreach ($modelNames as $k => $v) {
            $parent = \App\Model\Permission\Menu::create([
                'parent_id' => $grandParent->id,
                'name'  => $v['name'],
                'path'  =>  $v['path'],
                'component' => $v['component'],
                'meta'  =>  new \App\Model\Permission\Meta([
                    'type' => 'M',
                    'title' => $k . '管理',
                    'i18n' => $v['i18n'],
                    'icon' => $v['icon'],
                    'hidden' => 0,
                    'componentPath' => 'plugins/',
                    'componentSuffix' => '.vue',
                    'breadcrumbEnable' => 1,
                    'copyright' => 1,
                    'cache' => 1,
                    'affix' => 0,
                ]),
            ]);
            foreach ($listName as $k2 => $v2) {
                \App\Model\Permission\Menu::create([
                    'parent_id' => $parent->id,
                    'name' => $v['name'] . $v2['name'],
                    'meta'  =>  new \App\Model\Permission\Meta([
                        'i18n' => $v2['i18n'],
                        'type' => 'B',
                        'title' => $k . $k2
                    ])
                ]);
            }
        }
    }
}
